package com.central.common.feign

import com.baomidou.mybatisplus.extension.plugins.pagination.Page
import com.central.common.constant.ServiceNameConstants
import com.central.common.entity.Comment
import com.central.common.enum.CommentTypeEnum
import com.central.common.feign.fallback.CommentServiceFallbackFactory
import com.central.common.model.CommentRpcDto
import com.central.common.model.CommentVo
import com.central.common.model.PageVo
import com.central.common.model.SysUser
import org.springframework.cloud.openfeign.FeignClient
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestParam

/**
 * @author  fly
 * @date  2021/5/27 17:26
 * @version 1.0
 */
@FeignClient(name = ServiceNameConstants.COMMENT_SERVICE, fallbackFactory = CommentServiceFallbackFactory::class, decode404 = true)
interface CommentService {


    @PostMapping("/comment/insertRpcComment")
    fun insertComment(commentRpcDto: CommentRpcDto): Comment?


    /**
     * 获取某个帖子的全部评论信息
     */
    @GetMapping("/comment/getCommentVoListByRelevanceId")
    fun getCommentVoListByRelevanceId(
        @RequestParam("relevanceId") relevanceId: Long,
        @RequestParam("sysUser") sysUser: SysUser,
        @RequestParam("pageVo") pageVo: PageVo,
        @RequestParam("commentTypeEnum") commentTypeEnum: CommentTypeEnum
    ): Page<CommentVo>?


    /**
     * 获取某个类型的全部评论数量
     */
    @GetMapping("/comment/getCommentNumByRelevanceId")
    fun getCommentNumByRelevanceId(
        @RequestParam("relevanceId") relevanceId: Long,
        @RequestParam("commentTypeEnum") commentTypeEnum: CommentTypeEnum
    ): Long

    /**
     * 获取某个人在某个类型的全部评论信息
     */
    @GetMapping("/comment/getCommentVoListByUserId")
    fun getCommentVoListByUserId(
        @RequestParam("userId") userId: Long,
        @RequestParam("commentTypeEnum") commentTypeEnum: CommentTypeEnum
    ): List<Comment>?

    /**
     * 获取某个类型的全部评论人
     */
    @GetMapping("/comment/getCommentAllUserIds")
    fun getCommentAllUserIds(
        @RequestParam("commentTypeEnum") commentTypeEnum: CommentTypeEnum,
        @RequestParam("pageVo") pageVo: PageVo
    ): Page<Long>?

    /**
     * 根据内容评论人评论类型获取评论数据
     */
    @GetMapping("/comment/getCommentByContentAndUserIdAndTypeAndRelevanceId")
    fun getCommentByContentAndUserIdAndTypeAndRelevanceId(
        @RequestParam("content") content: String,
        @RequestParam("userId") userId: Long,
        @RequestParam("commentTypeEnum") commentTypeEnum: CommentTypeEnum,
        @RequestParam("relevanceId") relevanceId: Long
    ): Comment?
}
